package com.mvc.framework.dao;

import org.apache.log4j.Logger;
import org.hibernate.event.PostDeleteEvent;
import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.PostInsertEvent;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEvent;
import org.hibernate.event.PostUpdateEventListener;

import com.mvc.framework.model.CommonAuditableEntity;

public class HistoryListener implements PostInsertEventListener, PostUpdateEventListener, PostDeleteEventListener {

	private static final Logger LOGGER = Logger.getLogger(HistoryListener.class);
	@Override
	public void onPostInsert(PostInsertEvent event) {
		if (event.getEntity() instanceof CommonAuditableEntity) {
			LOGGER.debug("1");
		}
	}

	@Override
	public void onPostUpdate(PostUpdateEvent event) {
		if (event.getEntity() instanceof CommonAuditableEntity) {
			LOGGER.debug("2");
		}
	}

	@Override
	public void onPostDelete(PostDeleteEvent event) {
		if (event.getEntity() instanceof CommonAuditableEntity) {
			LOGGER.debug("3");
		}
	}
}
